#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

class olution {
public:
    bool lemonadeChange(vector<int>& bills) {
        int five = 0;
        int ten = 0;
        for (auto& e : bills) {
            if (e == 5)five++;
            else if (e == 10) {
                if (five == 0)return false;
                five--;
                ten++;
            }
            else {
                if (ten > 0 && five > 0) {
                    ten--;
                    five--;
                }
                else if (five >= 3)five -= 3;
                else return false;
            }
        }
        return true;
    }
};
bool func(string s1, string s2) {
    return s1 + s2 > s2 + s1;
}
class Solution {
public:
    string largestNumber(vector<int>& nums) {
        vector<string>strs;
        for (auto& e : nums)strs.push_back(to_string(e));
        sort(strs.begin(), strs.end(), func);
        string s;
        for (auto& e : strs)s += e;
        if (s[0] == '0')return "0";
        return s;
    }
};
class Soution {
public:
    int wiggleMaxLength(vector<int>& nums) {
        int n = nums.size();
        if (n < 2)return n;
        int ret = 0;
        int left = 0;
        int right = 0;
        for (int i = 0; i < n - 1; i++) {
            right = nums[i + 1] - nums[i];
            if (right == 0)continue;
            if (left * right <= 0)ret++;
            left = right;
        }
        return ret + 1;
    }
};
class Solution {
public:
    int wiggleMaxLength(vector<int>& nums) {
        int sum = 0;
        int left = 0;
        int right = 0;
        for (int i = 0; i < nums.size() - 1; i++) {
            right = nums[i] - nums[i + 1];
            if (right == 0)continue;
            else if (left * right <= 0)sum++;
            left = right;
        }
        return sum + 1;
    }
};
int main() {

}
